@isTest
public class MeasureCalcProductHandlerTest {

    static testMethod void testMethod1() {

        //客户1
        Account acc = TestUtils.createAccount();
        acc.Level__c = '三级甲等';
        insert acc;
        
        //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = acc.Id;
        insert opp;
        system.debug(opp+'=========================');
        System.Test.startTest();
        //报价1
        Quote qt = new Quote(Name = '测试报价', OpportunityId = opp.Id);
        insert qt;

        //产品1
        Product__c p1 = TestUtils.createProduct();    
        p1.Category1__c = '微生物';
        p1.Category0__c = '仪器';
        Product__c p2 = TestUtils.createProduct();
        p2.Name = 'Test1';
        p1.Category0__c = '试剂';
        p2.Category1__c = '免疫';   
        Product__c p3 = TestUtils.createProduct(); 
        p3.Name = 'Test2';   
        p3.Category1__c = '生化';
        p3.Category0__c = '仪器';     
        insert new Product__c[] {p1, p2, p3};

        //报价产品
      //  QuoteProduct__c qp1 = new QuoteProduct__c(Product__c = p3.Id, Quote__c = qt.Id);
        //insert qp1;

        //测算信息1
        Measure_Calculate__c mc = new Measure_Calculate__c(Opportunity__c = opp.Id);
        insert mc;

        //测算信息产品1
        Measure_Calculate_Product__c mcp1 = new Measure_Calculate_Product__c(Product__c = p1.Id, Measure_Calculate__c = mc.Id);
        Measure_Calculate_Product__c mcp2 = new Measure_Calculate_Product__c(Product__c = p2.Id, Measure_Calculate__c = mc.Id);
        insert new Measure_Calculate_Product__c[] {mcp1, mcp2};


        Opportunity insertOpp = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        system.debug(insertOpp.Id+'=============='+insertOpp.ProjectType__c);
        //system.assertEquals('多项目', insertOpp.ProjectType__c); 


        // mcp1.TestNum__c = 1;
        // System.Test.startTest();
        // update mcp1;
        // System.Test.stopTest();
        // System.Test.startTest();
        // delete mcp1;
        // System.Test.stopTest();
        // Opportunity deleteOpp = [select ProjectType__c,id from Opportunity where id = :opp.Id];
        // system.assertEquals('多项目', deleteOpp.ProjectType__c);

    }
    
}